namespace CSharpPro._0928;

public class Demo2
{
    public void work2(int n)
    {
        int[] each = new int [n+1];
        for (int i = 2; i <= n; ++i)
        {
            if (each[i] == 0)
            {
                for(int j=i*i;j<=n;j+=i)
                {
                    each[j] = 1;
                }
                Console.WriteLine(i);
            }
        }
    }
}